package com.situ.mall.design.singleton;

import com.situ.mall.javase.Student;

import java.util.ArrayList;
import java.util.List;

public class Singleton2 {
    //懒汉式
    private static Singleton2 INSTANCE;
    private List<Student> list = new ArrayList<>();

    private Singleton2() {
    }

    //线程安全问题
    public synchronized static Singleton2 getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new Singleton2();
        }
        return INSTANCE;
    }
}
